#include <stdio.h>
#include <string.h>
#include <stdarg.h>

int print_str_cat(int id, const char * prefix, int arg_cnt, ...)
{
   int val = 0;
   va_list ap;
   int i;

   char buff[1024] = {0};
   char * p = buff; 
   sprintf(p, "[%04d]-", id);
   p += 7;
   memcpy(p, prefix, strlen(prefix));
   p += strlen(prefix);

   const char *r_surrfix = "-: ";
   memcpy(p, r_surrfix, strlen(r_surrfix));
   p += strlen(r_surrfix);

   va_start(ap, arg_cnt);
   for (int i = 0; i < arg_cnt; i++) {
       char * arg_str = va_arg(ap, char *);
       memcpy(p, arg_str, strlen(arg_str));
       p += strlen(arg_str);
   }
   va_end(ap);
   printf("%s\n", buff);
 
   return val;
}



#define M_FUN(a, b, ...)                           \
do {                                               \
    char *p[] = {__VA_ARGS__};                     \
    int args_size = sizeof(p)/sizeof(char*);       \
    print_str_cat(a, b, args_size, ##__VA_ARGS__); \
} while(0)


int main()
{
    M_FUN(1, "CH");
    M_FUN(1, "CH", "a");
    M_FUN(1, "CH", "a", "b");
    return 0;
}

